package com.five.monkey.feign.provider.controller;

import com.five.monkey.feign.provider.service.GraphService;
import com.five.monkey.vo.CommonVo;
import com.five.monkey.vo.GraphVo;
import com.five.monkey.vo.PageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 狻猊
 * @date 2021/8/10 下午2:08
 */
@Api(value = "图服务相关接口")
@RestController
@RequestMapping("/provider/graph")
public class ProviderGraphController {

    @Autowired
    private GraphService graphService;

    @GetMapping("/find/by/{id}")
    @ApiOperation(value = "图谱主键查询接口", notes = "图谱主键查询接口", response = CommonVo.class)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "图谱主键", required = true, paramType = "path", dataType = "Long")
    })
    public CommonVo<GraphVo> findById(@PathVariable("id") Long id) {
        return CommonVo.ok(graphService.findById(id));
    }

    @GetMapping("/find/by/user/{userId}")
    @ApiOperation(value = "图谱用户查询", notes = "图谱用户查询", response = CommonVo.class)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "userId", value = "用户主键", required = true, paramType = "path", dataType = "Long")
    })
    public CommonVo<List<GraphVo>> findByUserId(@PathVariable("userId") Long userId) {
        return CommonVo.ok(graphService.findByUserId(userId));
    }
}
